# Maintainer: valadaa48 <valadaa48@gmx.com>

buildarch=12

_pkgname=linux-rga
pkgname=librga
pkgver=r36.72e7764
pkgrel=1
pkgdesc="Rockchip rga library"
arch=('aarch64' 'armv7h')
url="https://github.com/rockchip-linux/linux-rga"
license=('GPL2')
makedepends=('git')
source=('git+https://github.com/rockchip-linux/linux-rga'
        '50-rga.rules')
md5sums=('SKIP'
  'f1f632e0fd8787f40ed2bc5c5e411704')

pkgver() {
  cd "${_pkgname}"
  echo "r$(git rev-list --count HEAD).$(git rev-parse --short HEAD)"
}

prepare() {
  cd "${_pkgname}"
  # Change to release mode
  sed -i "s/DEBUG.*:= y/DEBUG :=/" Makefile
}

build() {
  cd "${_pkgname}"
  mkdir -p build
  make PROJECT_DIR=build
}

package() {
  cd "${_pkgname}"
  install -d "${pkgdir}"/usr/lib/udev/rules.d

  install -Dm644 {drmrga.h,RgaApi.h,rga.h,RockchipRgaMacro.h} -t "${pkgdir}"/usr/include/rga
  install -Dm755 build/lib/librga.so -t "${pkgdir}"/usr/lib

  cp "${srcdir}"/50-rga.rules "${pkgdir}"/usr/lib/udev/rules.d
}
